<?php

declare (strict_types=1);
namespace App\Model;

use App\Traits\ModelLabelTrait;
use Hyperf\Database\Model\SoftDeletes;
use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property string $name 
 * @property int $parent_id 
 * @property string $route_name 
 * @property string $query_params 
 * @property string $type 
 * @property int $lft 
 * @property int $rgt 
 * @property int $depth 
 * @property string $icon 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property string $deleted_at 
 */
class RbacMenu extends Model
{
    use SoftDeletes,ModelLabelTrait;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'rbac_menu';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'parent_id',
        'route_name',
        'route',
        'query_params',
        'type',
        'lft',
        'rgt',
        'depth',
        'icon',
        'listorder',
        'is_visable'
    ];

    protected $appends=[
        'type_label'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'parent_id' => 'integer', 'lft' => 'integer', 'rgt' => 'integer', 'depth' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    const TYPE_URL = 'menu';
    const TYPE_BTN = 'btn';

    const TYPE_LABELS=[
        self::TYPE_URL => '菜单',
        self::TYPE_BTN => '按钮'
    ];

    public function getTypeLabelAttribute(){
        return self::getLabel('type',$this->type);
    }

}